﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StyleMVVM.ViewModel
{
	public delegate void EventCommandAction(object sender, object args, object parameter);

	/// <summary>
	/// This class can be used with Attached Event Commands as a handler. The benifit of using this class
	/// over DelegateCommand is that AEC is designed to send the sender,args and parameter to Execute
	/// where as DelegateCommand works with ICommand and only sends the parameter
	/// </summary>
	public sealed class EventCommand : IEventCommand
	{
		private readonly EventCommandAction handler;

		public EventCommand(EventCommandAction handler)
		{
			this.handler = handler;
		}

		public void Execute(object sender, object args, object parameter)
		{
			handler(sender, args, parameter);
		}
	}
}